<template>
    <div>
         <!--优惠券记录-->
        <el-card class="box-card">
            <!--定义面包屑-->
            <el-breadcrumb separator=">">
                <el-breadcrumb-item :to="{ path: '/customer' }">首页</el-breadcrumb-item>
                <el-breadcrumb-item>系统管理</el-breadcrumb-item>
                <el-breadcrumb-item>角色管理</el-breadcrumb-item>
            </el-breadcrumb>
            <el-divider></el-divider>
            <!--表单的搜索框
                 :model="双向绑定表单的数据"
            -->
            <el-form :inline="true" :model="courecFormData"  class="demo-form-inline">
                <el-form-item >
<!--                    <el-input v-model="courecFormData.useTime" placeholder="请输入使用时间"></el-input>-->
                    <el-input v-model="courecFormData.name" placeholder="请输入客户名称"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary"  @click="initCourecTable">查询</el-button>
                </el-form-item>
            </el-form>

            <!--数据表格-->
            <template>
                <el-table
                        :data="tableData"
                        :border="true"
                        stripe
                        style="width: 100%">

                    <el-table-column
                            prop="tbClient.name"
                            label="客户名称"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="tbCoupon.couname"
                            label="优惠券名称"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="tbCoupon.amount"
                            label="优惠券金额"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="couponCode"
                            label="优惠券码"
                            align="center">
                    </el-table-column>

                    <el-table-column
                            prop="createTime"
                            label="获取时间"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="useTime"
                            label="使用时间"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="orderSn"
                            label="订单编号"
                            align="center">
                    </el-table-column>

                    <el-table-column label="操作" align="center">
                        <template slot-scope="scope">
                            <el-button type="danger" icon="el-icon-delete" circle @click="deleteCourec(scope.row.id)"></el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <!--分页-->
                <el-pagination
                        @size-change="handleSizeChange"
                        @current-change="handleCurrentChange"
                        :current-page="currentPage"
                        :page-sizes="[5, 10, 15, 20]"
                        :page-size="pageSize"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="total">
                </el-pagination>
            </template>
        </el-card>

    </div>
</template>

<script>
    export default {
        name: "Integration",
        data(){
            return{
                //条件搜索对象
                courecFormData:{},
                //表格数据
                tableData:[],
                //添加修改弹出框显示
                editDialogVisible:false,
                //添加用户表单信息
                levelForm:{},
                //当前的显示的页码
                currentPage:1,
                //每页显示的条数
                pageSize:5,
                //总条数
                total:0,
            }
        },
        created() {
            //获取客户的信息
            this.initCourecTable();
        },
        methods:{
            //分页查询
            initCourecTable(){
                //get方式不支持json数据
                var that=this;
                this.$http.post(`/client/courec/initCourecTable/${this.currentPage}/${this.pageSize}`,this.courecFormData).then(function(resp){
                    console.log(resp);
                    that.tableData=resp.data.result.records;
                    that.total=resp.data.result.total;
                });

            },
            //删除
            deleteCourec(id){
                var that=this;
                this.$http.delete(`/client/courec/deleteCourec/${id}`).then(function (resp) {
                    that.$message.success(resp.data.message);
                    that.initCourecTable();
                    // location.reload();
                })
                this.currentPage=1;
            },
            //当改变没有显示的条数时触发该方法
            handleSizeChange(v){
                this.pageSize=v;
                this.initCourecTable();
            },
            //切换页码时触发该方法
            handleCurrentChange(v){
                this.currentPage=v;
                this.initCourecTable();
            },

        },
    }
</script>

<style scoped>
</style>

